import re

raw ='''
{
 {i[0] (i[0] k[0] + j[0] k[1]) + j[0] (i[0] k[1] + j[0] k[2]), 
  i[1] (i[0] k[0] + j[0] k[1]) + j[1] (i[0] k[1] + j[0] k[2]), 
  i[2] (i[0] k[0] + j[0] k[1]) + j[2] (i[0] k[1] + j[0] k[2]), 
  i[0] (i[0] k[3] + j[0] k[4]) + j[0] (i[0] k[6] + j[0] k[7]), 
  i[1] (i[0] k[3] + j[0] k[4]) + j[1] (i[0] k[6] + j[0] k[7]), 
  i[2] (i[0] k[3] + j[0] k[4]) + j[2] (i[0] k[6] + j[0] k[7]), 
  i[0] (i[0] k[10] + j[0] k[11]) + j[0] (i[0] k[15] + j[0] k[16]), 
  i[1] (i[0] k[10] + j[0] k[11]) + j[1] (i[0] k[15] + j[0] k[16]), 
  i[2] (i[0] k[10] + j[0] k[11]) + j[2] (i[0] k[15] + j[0] k[16]), 
  i[0] (i[0] k[21] + j[0] k[22]) + j[0] (i[0] k[28] + j[0] k[29]), 
  i[1] (i[0] k[21] + j[0] k[22]) + j[1] (i[0] k[28] + j[0] k[29]), 
  i[2] (i[0] k[21] + j[0] k[22]) + j[2] (i[0] k[28] + j[0] k[29])},
 {0, i[1] (i[1] k[0] + j[1] k[1]) + j[1] (i[1] k[1] + j[1] k[2]), 
  i[2] (i[1] k[0] + j[1] k[1]) + j[2] (i[1] k[1] + j[1] k[2]), 
  i[0] (i[1] k[3] + j[1] k[4]) + j[0] (i[1] k[6] + j[1] k[7]), 
  i[1] (i[1] k[3] + j[1] k[4]) + j[1] (i[1] k[6] + j[1] k[7]), 
  i[2] (i[1] k[3] + j[1] k[4]) + j[2] (i[1] k[6] + j[1] k[7]), 
  i[0] (i[1] k[10] + j[1] k[11]) + j[0] (i[1] k[15] + j[1] k[16]), 
  i[1] (i[1] k[10] + j[1] k[11]) + j[1] (i[1] k[15] + j[1] k[16]), 
  i[2] (i[1] k[10] + j[1] k[11]) + j[2] (i[1] k[15] + j[1] k[16]), 
  i[0] (i[1] k[21] + j[1] k[22]) + j[0] (i[1] k[28] + j[1] k[29]), 
  i[1] (i[1] k[21] + j[1] k[22]) + j[1] (i[1] k[28] + j[1] k[29]), 
  i[2] (i[1] k[21] + j[1] k[22]) + j[2] (i[1] k[28] + j[1] k[29])},
 {0, 0, i[2] (i[2] k[0] + j[2] k[1]) + j[2] (i[2] k[1] + j[2] k[2]), 
  i[0] (i[2] k[3] + j[2] k[4]) + j[0] (i[2] k[6] + j[2] k[7]), 
  i[1] (i[2] k[3] + j[2] k[4]) + j[1] (i[2] k[6] + j[2] k[7]), 
  i[2] (i[2] k[3] + j[2] k[4]) + j[2] (i[2] k[6] + j[2] k[7]), 
  i[0] (i[2] k[10] + j[2] k[11]) + j[0] (i[2] k[15] + j[2] k[16]), 
  i[1] (i[2] k[10] + j[2] k[11]) + j[1] (i[2] k[15] + j[2] k[16]), 
  i[2] (i[2] k[10] + j[2] k[11]) + j[2] (i[2] k[15] + j[2] k[16]), 
  i[0] (i[2] k[21] + j[2] k[22]) + j[0] (i[2] k[28] + j[2] k[29]), 
  i[1] (i[2] k[21] + j[2] k[22]) + j[1] (i[2] k[28] + j[2] k[29]), 
  i[2] (i[2] k[21] + j[2] k[22]) + j[2] (i[2] k[28] + j[2] k[29])},
 {0, 0, 0, 
  i[0] (i[0] k[5] + j[0] k[8]) + j[0] (i[0] k[8] + j[0] k[9]), 
  i[1] (i[0] k[5] + j[0] k[8]) + j[1] (i[0] k[8] + j[0] k[9]), 
  i[2] (i[0] k[5] + j[0] k[8]) + j[2] (i[0] k[8] + j[0] k[9]), 
  i[0] (i[0] k[12] + j[0] k[13]) + j[0] (i[0] k[17] + j[0] k[18]), 
  i[1] (i[0] k[12] + j[0] k[13]) + j[1] (i[0] k[17] + j[0] k[18]), 
  i[2] (i[0] k[12] + j[0] k[13]) + j[2] (i[0] k[17] + j[0] k[18]), 
  i[0] (i[0] k[23] + j[0] k[24]) + j[0] (i[0] k[30] + j[0] k[31]), 
  i[1] (i[0] k[23] + j[0] k[24]) + j[1] (i[0] k[30] + j[0] k[31]), 
  i[2] (i[0] k[23] + j[0] k[24]) + j[2] (i[0] k[30] + j[0] k[31])},
 {0, 0, 0, 0, 
  i[1] (i[1] k[5] + j[1] k[8]) + j[1] (i[1] k[8] + j[1] k[9]), 
  i[2] (i[1] k[5] + j[1] k[8]) + j[2] (i[1] k[8] + j[1] k[9]), 
  i[0] (i[1] k[12] + j[1] k[13]) + j[0] (i[1] k[17] + j[1] k[18]), 
  i[1] (i[1] k[12] + j[1] k[13]) + j[1] (i[1] k[17] + j[1] k[18]), 
  i[2] (i[1] k[12] + j[1] k[13]) + j[2] (i[1] k[17] + j[1] k[18]), 
  i[0] (i[1] k[23] + j[1] k[24]) + j[0] (i[1] k[30] + j[1] k[31]), 
  i[1] (i[1] k[23] + j[1] k[24]) + j[1] (i[1] k[30] + j[1] k[31]), 
  i[2] (i[1] k[23] + j[1] k[24]) + j[2] (i[1] k[30] + j[1] k[31])},
 {0, 0, 0, 0, 0, 
  i[2] (i[2] k[5] + j[2] k[8]) + j[2] (i[2] k[8] + j[2] k[9]), 
  i[0] (i[2] k[12] + j[2] k[13]) + j[0] (i[2] k[17] + j[2] k[18]), 
  i[1] (i[2] k[12] + j[2] k[13]) + j[1] (i[2] k[17] + j[2] k[18]), 
  i[2] (i[2] k[12] + j[2] k[13]) + j[2] (i[2] k[17] + j[2] k[18]), 
  i[0] (i[2] k[23] + j[2] k[24]) + j[0] (i[2] k[30] + j[2] k[31]), 
  i[1] (i[2] k[23] + j[2] k[24]) + j[1] (i[2] k[30] + j[2] k[31]), 
  i[2] (i[2] k[23] + j[2] k[24]) + j[2] (i[2] k[30] + j[2] k[31])},
 {0, 0, 0, 0, 0, 0, 
  i[0] (i[0] k[14] + j[0] k[19]) + j[0] (i[0] k[19] + j[0] k[20]), 
  i[1] (i[0] k[14] + j[0] k[19]) + j[1] (i[0] k[19] + j[0] k[20]), 
  i[2] (i[0] k[14] + j[0] k[19]) + j[2] (i[0] k[19] + j[0] k[20]), 
  i[0] (i[0] k[25] + j[0] k[26]) + j[0] (i[0] k[32] + j[0] k[33]), 
  i[1] (i[0] k[25] + j[0] k[26]) + j[1] (i[0] k[32] + j[0] k[33]), 
  i[2] (i[0] k[25] + j[0] k[26]) + j[2] (i[0] k[32] + j[0] k[33])},
 {0, 0, 0, 0, 0, 0, 0, 
  i[1] (i[1] k[14] + j[1] k[19]) + j[1] (i[1] k[19] + j[1] k[20]), 
  i[2] (i[1] k[14] + j[1] k[19]) + j[2] (i[1] k[19] + j[1] k[20]), 
  i[0] (i[1] k[25] + j[1] k[26]) + j[0] (i[1] k[32] + j[1] k[33]), 
  i[1] (i[1] k[25] + j[1] k[26]) + j[1] (i[1] k[32] + j[1] k[33]), 
  i[2] (i[1] k[25] + j[1] k[26]) + j[2] (i[1] k[32] + j[1] k[33])},
 {0, 0, 0, 0, 0, 0, 0, 0, 
  i[2] (i[2] k[14] + j[2] k[19]) + j[2] (i[2] k[19] + j[2] k[20]), 
  i[0] (i[2] k[25] + j[2] k[26]) + j[0] (i[2] k[32] + j[2] k[33]), 
  i[1] (i[2] k[25] + j[2] k[26]) + j[1] (i[2] k[32] + j[2] k[33]), 
  i[2] (i[2] k[25] + j[2] k[26]) + j[2] (i[2] k[32] + j[2] k[33])},
 {0, 0, 0, 0, 0, 0, 0, 0, 0, 
  i[0] (i[0] k[27] + j[0] k[34]) + j[0] (i[0] k[34] + j[0] k[35]), 
  i[1] (i[0] k[27] + j[0] k[34]) + j[1] (i[0] k[34] + j[0] k[35]), 
  i[2] (i[0] k[27] + j[0] k[34]) + j[2] (i[0] k[34] + j[0] k[35])},
 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  i[1] (i[1] k[27] + j[1] k[34]) + j[1] (i[1] k[34] + j[1] k[35]), 
  i[2] (i[1] k[27] + j[1] k[34]) + j[2] (i[1] k[34] + j[1] k[35])},
 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  i[2] (i[2] k[27] + j[2] k[34]) + j[2] (i[2] k[34] + j[2] k[35])}
}
'''

raw = re.sub(r'[\n\{\}]', '', raw)
raw = re.sub('\s+', ' ', raw)
raw = re.sub('^ ', '', raw)
raw = re.sub(r'\] \(', '] * (', raw)
raw = re.sub(r'\] k', '] * k', raw)
raws = raw.split(', ')
# print(raws)
K = [raws[12*i:12*(i+1)] for i in range(12)]

count = 0
for j in range(12):
    for i in range(j,-1,-1):
        print('    Matrix[%d] = %s;'%(count, K[i][j]))
        count += 1


# i = 0
# for raw in raws:
#     if not raw:
#         continue
#     else:
#         raw = re.sub('^\s+', '', raw)
#         raw = re.sub('\s+$', '', raw)
#         print('    Matrix[%d] = %s;'%(i, raw))
#         i += 1